import { ComponentInterface } from "../../core/Component";
import Container, { Alignment } from "../../layout/Container";

export default class H5Container extends Container {
  element: HTMLDivElement
  backgroundColor?: string
  constructor(options: {
    child?: ComponentInterface
    alignment?: Alignment
    backgroundColor?: string
    x?: number
    y?: number
    width?: number
    height?: number
  }) {
    super(options)
    this.backgroundColor = options.backgroundColor
  }

  async init(): Promise<void> {
    this.element = document.createElement('div')
    document.body.appendChild(this.element)
    await super.init()
  }

  async resize(): Promise<void> {
    super.resize()
    this.element.style.width = this.width + 'px'
    this.element.style.height = this.height + 'px'
    this.element.style.top = this.y + 'px'
    this.element.style.left = this.x + 'px'
    this.element.style.position = 'absolute'
    this.element.style.backgroundColor = this.backgroundColor
  }
}